﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class inc_location : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        load_location();
    }
    void load_location()
    {
        String sql = "select top 1 name,father_id,url,pageLocation from channel where  pageLocation='" + Request["channel"] + "'";

        DataTable dt = DB.getDataTable(sql);
        if (dt.Rows.Count > 0)
        {
            String str = "";
            if (dt.Rows[0]["father_id"] != null && Int16.Parse(dt.Rows[0]["father_id"].ToString()) > 1)
            {
                String sql1 = "select top 1 name,url,pageLocation from channel where  channel_id=" + dt.Rows[0]["father_id"];

                DataTable dt1 = DB.getDataTable(sql1);
                if (dt1.Rows.Count > 0)
                {
                    str += "<a href='" + dt1.Rows[0]["url"].ToString() + 
                        (dt1.Rows[0]["url"].ToString().IndexOf("?") > -1 ? "&" : "?") + "channel=" +
                        dt1.Rows[0]["pageLocation"].ToString() + "'>" + dt1.Rows[0]["name"].ToString() + "</a>  -> ";
                }
            }
            str += "<a href='" + dt.Rows[0]["url"].ToString() +
                (dt.Rows[0]["url"].ToString().IndexOf("?") > -1 ? "&" : "?") + "channel=" +
                dt.Rows[0]["pageLocation"].ToString() + "'>" + dt.Rows[0]["name"].ToString() + "</a>";
            location.Text = str;
        }
    }
}
